package com.dyz.leetcode._19_greedy;

public class _409_longestPalindrome {
    public int longestPalindrome(String s) {
        int [] counter = new int[128];//字符总共128个，包含大小写
        for (char c :s.toCharArray()){
            counter[c]++;
        }

        int ans = 0;
        for (int v:counter){
            ans += v/2*2;
            //中间只能有依次出现出现奇数的字符
            if(v%2==1 && ans%2==0){
                ans++;
            }
        }
        return ans;
    }
}
